package com.snowleopard.findpeople.service.publish;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.snowleopard.common.base.BaseDao;
import com.snowleopard.common.base.BaseServiceImpl;
import com.snowleopard.findpeople.dao.publish.ImageStorageDao;
import com.snowleopard.findpeople.dao.publish.InfoPublishDao;
import com.snowleopard.findpeople.entity.publish.ImageStorage;
import com.snowleopard.findpeople.entity.publish.InfoPublish;

@Service
@Transactional
public class ImageStorageManager extends BaseServiceImpl<ImageStorage, String> {
    @Autowired
    private ImageStorageDao imageStorageDao;

    @Autowired
    private InfoPublishDao infoPublishDao;

    @Override
    protected BaseDao<ImageStorage, String> getDao() {
        return imageStorageDao;
    }

    public void save(ImageStorage imageStorage, String infoPublishId) {
        InfoPublish infoPublish = infoPublishDao.get(infoPublishId);
        imageStorage.setInfoPublish(infoPublish);

        save(imageStorage);
    }

}
